import pymysql

# 创建连接
conn=pymysql.connect(
	user='mn',
	password='a16651898',
	host='2409:8a5c:4822:3270:80cc:1212:a023:2',
	database='blog',
	port=3306,
)
# 创建游标
cursor=conn.cursor()
metadata='{"ip": "192.168.1.1", "device": "iPhone"}'
sql='insert into comments (content, user_id, username, post_id, status)' \
	f"VALUES ('这是一条评论内容商城', 1, 'john_doe', 101, 'approved');"

try:
	result=cursor.execute(sql)
	print('-'*30)
	print(f'result',result)
	print('-'*30)
	conn.commit()
except e:
	conn.rollback()
finally:
	if cursor:
		cursor.close()
	conn.close()



